
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>1.图论 · 计算机 ,java , 大数据 基础知识体系</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="hzh">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="2.图论例题.html" />
    
    
    <link rel="prev" href="../计算机网络/9.面试题二.html" />
    

    
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">操作系统</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../操作系统/1.基本概述.html">
            
                <a href="../操作系统/1.基本概述.html">
            
                    
                    1.操作系统基本概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../操作系统/2.进程管理之进程与线程.html">
            
                <a href="../操作系统/2.进程管理之进程与线程.html">
            
                    
                    2.进程管理之进程与线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../操作系统/3.进程管理之处理机调度.html">
            
                <a href="../操作系统/3.进程管理之处理机调度.html">
            
                    
                    3.进程管理之处理机调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../操作系统/4.进程管理之进程同步.html">
            
                <a href="../操作系统/4.进程管理之进程同步.html">
            
                    
                    4.进程管理之进程同步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../操作系统/5.内存管理之基本概念.html">
            
                <a href="../操作系统/5.内存管理之基本概念.html">
            
                    
                    5.内存管理之基本概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../操作系统/6.内存管理之虚拟内存.html">
            
                <a href="../操作系统/6.内存管理之虚拟内存.html">
            
                    
                    6.内存管理之虚拟内存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../操作系统/7.IO设备管理之基本概念.html">
            
                <a href="../操作系统/7.IO设备管理之基本概念.html">
            
                    
                    7.IO设备管理之基本概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../操作系统/8.面试题总结一.html">
            
                <a href="../操作系统/8.面试题总结一.html">
            
                    
                    8.面试题总结一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">计算机网络篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../计算机网络/1.计算机网络入门基础概念.html">
            
                <a href="../计算机网络/1.计算机网络入门基础概念.html">
            
                    
                    1.计算机网络入门文章(必读)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../计算机网络/2.计算机网络通信基础.html">
            
                <a href="../计算机网络/2.计算机网络通信基础.html">
            
                    
                    2.计算机网络通信入门文章(必读)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../计算机网络/3.数据链路层.html">
            
                <a href="../计算机网络/3.数据链路层.html">
            
                    
                    3.数据链路层
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../计算机网络/4.网络层1.html">
            
                <a href="../计算机网络/4.网络层1.html">
            
                    
                    4.网络层(一)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../计算机网络/5.网络层2.html">
            
                <a href="../计算机网络/5.网络层2.html">
            
                    
                    5.网络层(二)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../计算机网络/6.传输层.html">
            
                <a href="../计算机网络/6.传输层.html">
            
                    
                    6.传输层
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="../计算机网络/7.应用层.html">
            
                <a href="../计算机网络/7.应用层.html">
            
                    
                    7.应用层(⭐)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="../计算机网络/10.HTTP相关协议.html">
            
                <a href="../计算机网络/10.HTTP相关协议.html">
            
                    
                    8.HTTP相关及发展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.9" >
            
                <span>
            
                    
                    9.websocket
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="../计算机网络/9.面试题二.html">
            
                <a href="../计算机网络/9.面试题二.html">
            
                    
                    面试题总结一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">数据结构篇</li>
        
        
    
        <li class="chapter active" data-level="3.1" data-path="1.图论.html">
            
                <a href="1.图论.html">
            
                    
                    1.图论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="2.图论例题.html">
            
                <a href="2.图论例题.html">
            
                    
                    2.图论例题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="3.散列表.html">
            
                <a href="3.散列表.html">
            
                    
                    3.散列表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="4.排序算法.html">
            
                <a href="4.排序算法.html">
            
                    
                    4.排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="5.排序列题.html">
            
                <a href="5.排序列题.html">
            
                    
                    5.排序算法例题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="6.树论.html">
            
                <a href="6.树论.html">
            
                    
                    6.树论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="7.树论例题.html">
            
                <a href="7.树论例题.html">
            
                    
                    7.树论例题.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="9.模板.html">
            
                <a href="9.模板.html">
            
                    
                    数据结构模板
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">算法篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../算法/leetCode周赛题解.html">
            
                <a href="../算法/leetCode周赛题解.html">
            
                    
                    leetCode周赛记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../算法/1.时间复杂度.html">
            
                <a href="../算法/1.时间复杂度.html">
            
                    
                    1.时间复杂度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../算法/2.深度优先搜索.html">
            
                <a href="../算法/2.深度优先搜索.html">
            
                    
                    2.深度优先搜索算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../算法/2.深度优先搜索题目集.html">
            
                <a href="../算法/2.深度优先搜索题目集.html">
            
                    
                    2.深搜题目集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../算法/3.广度优先搜索.html">
            
                <a href="../算法/3.广度优先搜索.html">
            
                    
                    3.广度优先搜索算法
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JVM篇</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../jvm/1.jvm内存结构.html">
            
                <a href="../jvm/1.jvm内存结构.html">
            
                    
                    1.jvm内存结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../jvm/2.HotSpot虚拟机对象探秘.html">
            
                <a href="../jvm/2.HotSpot虚拟机对象探秘.html">
            
                    
                    2.HotSpot虚拟机对象探秘.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../jvm/3.对象存亡与垃圾收集算法.html">
            
                <a href="../jvm/3.对象存亡与垃圾收集算法.html">
            
                    
                    3.对象存亡与垃圾收集算法.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../jvm/4.HotSpot的算法细节与垃圾收集器.html">
            
                <a href="../jvm/4.HotSpot的算法细节与垃圾收集器.html">
            
                    
                    4.HotSpot的算法细节与垃圾收集器.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="../jvm/5.内存分配与回收策略.html">
            
                <a href="../jvm/5.内存分配与回收策略.html">
            
                    
                    5.内存分配与回收策略.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="../jvm/6.类文件结构.html">
            
                <a href="../jvm/6.类文件结构.html">
            
                    
                    6.类文件结构.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="../jvm/7.类加载机制.html">
            
                <a href="../jvm/7.类加载机制.html">
            
                    
                    7.类加载机制.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="../jvm/8.jvm逃逸分析.html">
            
                <a href="../jvm/8.jvm逃逸分析.html">
            
                    
                    8.逃逸分析技术
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">多线程篇</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../多线程/basic/0.多线程路线图.html">
            
                <a href="../多线程/basic/0.多线程路线图.html">
            
                    
                    1.多线程学习路线图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../多线程/basic/0.java内存模型与线程.html">
            
                <a href="../多线程/basic/0.java内存模型与线程.html">
            
                    
                    2.java内存模型与线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../多线程/3.并行程序基础.html">
            
                <a href="../多线程/3.并行程序基础.html">
            
                    
                    2.并行程序基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../多线程/basic/0.jhappenBefore与jvm指令重排.html">
            
                <a href="../多线程/basic/0.jhappenBefore与jvm指令重排.html">
            
                    
                    3.happenBefore与jvm指令重排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="../多线程/basic/1.synchronized与volatile.html">
            
                <a href="../多线程/basic/1.synchronized与volatile.html">
            
                    
                    4.synchronized与volatile.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="../多线程/basic/2.ThreadLocal.html">
            
                <a href="../多线程/basic/2.ThreadLocal.html">
            
                    
                    5.ThreadLocal.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="../多线程/cas/1.乐观锁与悲观锁.html">
            
                <a href="../多线程/cas/1.乐观锁与悲观锁.html">
            
                    
                    6.乐观锁与悲观锁.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="../多线程/cas/2.CAS与atomic类.html">
            
                <a href="../多线程/cas/2.CAS与atomic类.html">
            
                    
                    7.CAS与atomic类.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="../多线程/aqs/1.AQS.html">
            
                <a href="../多线程/aqs/1.AQS.html">
            
                    
                    8.AQS.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.10" data-path="../多线程/aqs/2.基于AQS的并发工具.html">
            
                <a href="../多线程/aqs/2.基于AQS的并发工具.html">
            
                    
                    9.基于AQS的并发工具.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.11" data-path="../多线程/blockingQueue/1.阻塞队列.html">
            
                <a href="../多线程/blockingQueue/1.阻塞队列.html">
            
                    
                    10.阻塞队列.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.12" data-path="../多线程/pond/1.线程池与底层原理.html">
            
                <a href="../多线程/pond/1.线程池与底层原理.html">
            
                    
                    11.线程池与底层原理.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.13" data-path="../多线程/10面试题一.html">
            
                <a href="../多线程/10面试题一.html">
            
                    
                    12.面试题一
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.14" data-path="../多线程/10面试题二.html">
            
                <a href="../多线程/10面试题二.html">
            
                    
                    13.面试题二.md
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">java集合篇</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../basic/collection/1.java集合.html">
            
                <a href="../basic/collection/1.java集合.html">
            
                    
                    1.集合架构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../basic/collection/2.HashMap源码分析.html">
            
                <a href="../basic/collection/2.HashMap源码分析.html">
            
                    
                    2.hashMap底层原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../basic/collection/3.ConcurrentHashMap分析.html">
            
                <a href="../basic/collection/3.ConcurrentHashMap分析.html">
            
                    
                    3.ConcurrentHashMap分析
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">设计模式篇</li>
        
        
    
        <li class="chapter " data-level="8.1" >
            
                <span>
            
                    
                    1.创造型模式
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="../设计模式/factory/三种工厂模式介绍.html">
            
                <a href="../设计模式/factory/三种工厂模式介绍.html">
            
                    
                    三种工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="../设计模式/factory/实战工厂模式.html">
            
                <a href="../设计模式/factory/实战工厂模式.html">
            
                    
                    实战工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="../设计模式/factory/实战抽象工厂模式.html">
            
                <a href="../设计模式/factory/实战抽象工厂模式.html">
            
                    
                    实战抽象工厂模式
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">mysql篇</li>
        
        
    
        <li class="chapter " data-level="9.1" data-path="../数据库/mysql/1.b树b+树的底层原理.html">
            
                <a href="../数据库/mysql/1.b树b+树的底层原理.html">
            
                    
                    1.mysql索引基础之b树与b+树⭐⭐
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="../数据库/mysql/2.mysql索引.html">
            
                <a href="../数据库/mysql/2.mysql索引.html">
            
                    
                    2.mysql索引及优化⭐⭐⭐⭐
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.3" data-path="../数据库/mysql/3.mysql存储引擎.html">
            
                <a href="../数据库/mysql/3.mysql存储引擎.html">
            
                    
                    3.mysql存储引擎.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.4" data-path="../数据库/mysql/4.多版本并发控制之mvcc原理.html">
            
                <a href="../数据库/mysql/4.多版本并发控制之mvcc原理.html">
            
                    
                    4.多版本并发控制之mvcc原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.5" data-path="../数据库/mysql/4.mysql事务.html">
            
                <a href="../数据库/mysql/4.mysql事务.html">
            
                    
                    5.mysql事务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.6" data-path="../数据库/mysql/5.mysql锁机制.html">
            
                <a href="../数据库/mysql/5.mysql锁机制.html">
            
                    
                    6.mysql的锁机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.7" data-path="../数据库/mysql/6.mysql面试题一.html">
            
                <a href="../数据库/mysql/6.mysql面试题一.html">
            
                    
                    7.mysql面试题一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">高并发中间件篇</li>
        
        
    

    
        
        <li class="header">架构理论篇</li>
        
        
    
        <li class="chapter " data-level="11.1" data-path="../架构/0.架构演进.html">
            
                <a href="../架构/0.架构演进.html">
            
                    
                    1.架构演进
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="11.2" data-path="../架构/0.微服务架构与soa架构.html">
            
                <a href="../架构/0.微服务架构与soa架构.html">
            
                    
                    2.微服务架构与soa架构
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">高可用系统篇</li>
        
        
    
        <li class="chapter " data-level="12.1" data-path="../高可用架构/1.限流.html">
            
                <a href="../高可用架构/1.限流.html">
            
                    
                    1.系统限流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="12.2" data-path="../高可用系统/2.服务熔断.html">
            
                <a href="../高可用系统/2.服务熔断.html">
            
                    
                    2.服务熔断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="12.3" data-path="../高可用系统/3.服务降级.html">
            
                <a href="../高可用系统/3.服务降级.html">
            
                    
                    3.服务降级
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">spring-cloud 微服务篇</li>
        
        
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >1.图论</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#&#x4E00;--&#x56FE;&#x7684;&#x8868;&#x793A;&#x4E0E;&#x904D;&#x5386;"><b></b>&#x4E00;  &#x56FE;&#x7684;&#x8868;&#x793A;&#x4E0E;&#x904D;&#x5386;</a></li><ul><li><span class="title-icon "></span><a href="#1&#x90BB;&#x63A5;&#x77E9;&#x9635;"><b></b>1.&#x90BB;&#x63A5;&#x77E9;&#x9635;</a></li><li><span class="title-icon "></span><a href="#2&#x90BB;&#x63A5;&#x8868;"><b></b>2.&#x90BB;&#x63A5;&#x8868;</a></li><li><span class="title-icon "></span><a href="#3dfs&#x904D;&#x5386;"><b></b>3.dfs&#x904D;&#x5386;</a></li><li><span class="title-icon "></span><a href="#4bfs&#x904D;&#x5386;"><b></b>4.bfs&#x904D;&#x5386;</a></li></ul><li><span class="title-icon "></span><a href="#&#x4E8C;-&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;"><b></b>&#x4E8C; &#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;</a></li><ul><li><span class="title-icon "></span><a href="#1dijkstra-&#x7B97;&#x6CD5;--&#x5355;&#x6E90;&#x6709;&#x6743;&#x6700;&#x77ED;&#x8DEF;"><b></b>1.Dijkstra &#x7B97;&#x6CD5;  &#x5355;&#x6E90;&#x6709;&#x6743;&#x6700;&#x77ED;&#x8DEF;</a></li><li><span class="title-icon "></span><a href="#2floyd&#x7B97;&#x6CD5;--&#x591A;&#x6E90;&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;"><b></b>2.Floyd&#x7B97;&#x6CD5;  &#x591A;&#x6E90;&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;</a></li></ul><li><span class="title-icon "></span><a href="#&#x4E09;-&#x5E76;&#x67E5;&#x96C6;"><b></b>&#x4E09; &#x5E76;&#x67E5;&#x96C6;</a></li><ul><li><span class="title-icon "></span><a href="#1&#x5B9A;&#x4E49;"><b></b>1.&#x5B9A;&#x4E49;</a></li><li><span class="title-icon "></span><a href="#2&#x6A21;&#x677F;"><b></b>2.&#x6A21;&#x677F;</a></li></ul><li><span class="title-icon "></span><a href="#&#x56DB;-&#x62D3;&#x6251;&#x6392;&#x5E8F;"><b></b>&#x56DB; &#x62D3;&#x6251;&#x6392;&#x5E8F;</a></li><ul><li><span class="title-icon "></span><a href="#1&#x5B9A;&#x4E49;_1"><b></b>1.&#x5B9A;&#x4E49;</a></li><li><span class="title-icon "></span><a href="#2&#x6A21;&#x677F;_1"><b></b>2.&#x6A21;&#x677F;:</a></li></ul><li><span class="title-icon "></span><a href="#&#x4E94;-&#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;"><b></b>&#x4E94; &#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;</a></li><ul><li><span class="title-icon "></span><a href="#0&#x5B9A;&#x4E49;"><b></b>0.&#x5B9A;&#x4E49;</a></li><li><span class="title-icon "></span><a href="#1prim&#x7B97;&#x6CD5;"><b></b>1.Prim&#x7B97;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#2kruskal-&#x7B97;&#x6CD5;"><b></b>2.Kruskal &#x7B97;&#x6CD5;</a></li></ul><li><span class="title-icon "></span><a href="#&#x516D;-&#x4E8C;&#x5206;&#x56FE;"><b></b>&#x516D; &#x4E8C;&#x5206;&#x56FE;</a></li><ul><li><span class="title-icon "></span><a href="#1&#x5B9A;&#x4E49;_2"><b></b>1.&#x5B9A;&#x4E49;</a></li><li><span class="title-icon "></span><a href="#2&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x5224;&#x65AD;"><b></b>2.&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x5224;&#x65AD;</a></li><li><span class="title-icon "></span><a href="#3&#x6700;&#x5927;&#x5339;&#x914D;"><b></b>3.&#x6700;&#x5927;&#x5339;&#x914D;</a></li><li><span class="title-icon "></span><a href="#4&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;"><b></b>4.&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h2 id="&#x4E00;--&#x56FE;&#x7684;&#x8868;&#x793A;&#x4E0E;&#x904D;&#x5386;"><a name="&#x4E00;--&#x56FE;&#x7684;&#x8868;&#x793A;&#x4E0E;&#x904D;&#x5386;" class="anchor-navigation-ex-anchor" href="#&#x4E00;--&#x56FE;&#x7684;&#x8868;&#x793A;&#x4E0E;&#x904D;&#x5386;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E00;--&#x56FE;&#x7684;&#x8868;&#x793A;&#x4E0E;&#x904D;&#x5386;" class="plugin-anchor" href="#&#x4E00;--&#x56FE;&#x7684;&#x8868;&#x793A;&#x4E0E;&#x904D;&#x5386;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E00;  &#x56FE;&#x7684;&#x8868;&#x793A;&#x4E0E;&#x904D;&#x5386;</h2>
<h3 id="1&#x90BB;&#x63A5;&#x77E9;&#x9635;"><a name="1&#x90BB;&#x63A5;&#x77E9;&#x9635;" class="anchor-navigation-ex-anchor" href="#1&#x90BB;&#x63A5;&#x77E9;&#x9635;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x90BB;&#x63A5;&#x77E9;&#x9635;" class="plugin-anchor" href="#1&#x90BB;&#x63A5;&#x77E9;&#x9635;"><i class="fa fa-link" aria-hidden="true"></i></a>1.&#x90BB;&#x63A5;&#x77E9;&#x9635;</h3>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201128111757.jpeg" alt="img"></p>
<h3 id="2&#x90BB;&#x63A5;&#x8868;"><a name="2&#x90BB;&#x63A5;&#x8868;" class="anchor-navigation-ex-anchor" href="#2&#x90BB;&#x63A5;&#x8868;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2&#x90BB;&#x63A5;&#x8868;" class="plugin-anchor" href="#2&#x90BB;&#x63A5;&#x8868;"><i class="fa fa-link" aria-hidden="true"></i></a>2.&#x90BB;&#x63A5;&#x8868;</h3>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201128111804.jpeg" alt="img"></p>
<p>&#x90BB;&#x63A5;&#x8868;&#x6A21;&#x677F;:</p>
<pre><code>    typedef pair&lt;int,int&gt; ll;
    map&lt;int,vector&lt;ll&gt;&gt; graph;
    //&#x521D;&#x59CB;&#x5316;
    .....
    //
    for (int i=0;i&lt;m;i++){
        cin&gt;&gt;a&gt;&gt;b&gt;&gt;value;
        graph[a].push_back({b,value});
        graph[b].push_back({a,value});
    }
</code></pre><h3 id="3dfs&#x904D;&#x5386;"><a name="3dfs&#x904D;&#x5386;" class="anchor-navigation-ex-anchor" href="#3dfs&#x904D;&#x5386;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="3dfs&#x904D;&#x5386;" class="plugin-anchor" href="#3dfs&#x904D;&#x5386;"><i class="fa fa-link" aria-hidden="true"></i></a>3.dfs&#x904D;&#x5386;</h3>
<pre><code>void DFS ( Vertex V ){
    visited[ V ] = true;
    for ( V &#x7684;&#x6BCF;&#x4E2A;&#x90BB;&#x63A5;&#x70B9; W )
        if( !visited[ W ])
            DFS( W );
}
</code></pre><h3 id="4bfs&#x904D;&#x5386;"><a name="4bfs&#x904D;&#x5386;" class="anchor-navigation-ex-anchor" href="#4bfs&#x904D;&#x5386;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="4bfs&#x904D;&#x5386;" class="plugin-anchor" href="#4bfs&#x904D;&#x5386;"><i class="fa fa-link" aria-hidden="true"></i></a>4.bfs&#x904D;&#x5386;</h3>
<pre><code>void BFS( Vertex V ){
    queue&lt;Vertex&gt; q;
    visited[V] = true;
    q.push(V);
    while(!q.empty()){
        V = q.front(); q.pop();
        for( V &#x7684;&#x6BCF;&#x4E2A;&#x90BB;&#x63A5;&#x70B9; W ){
            if( !visited[ W ]){
                visited[W] = true;
                q.push(W);
            }
        }
    }
}
</code></pre><h2 id="&#x4E8C;-&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;"><a name="&#x4E8C;-&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x4E8C;-&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E8C;-&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;" class="plugin-anchor" href="#&#x4E8C;-&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E8C; &#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;</h2>
<h3 id="1dijkstra-&#x7B97;&#x6CD5;--&#x5355;&#x6E90;&#x6709;&#x6743;&#x6700;&#x77ED;&#x8DEF;"><a name="1dijkstra-&#x7B97;&#x6CD5;--&#x5355;&#x6E90;&#x6709;&#x6743;&#x6700;&#x77ED;&#x8DEF;" class="anchor-navigation-ex-anchor" href="#1dijkstra-&#x7B97;&#x6CD5;--&#x5355;&#x6E90;&#x6709;&#x6743;&#x6700;&#x77ED;&#x8DEF;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1dijkstra-&#x7B97;&#x6CD5;--&#x5355;&#x6E90;&#x6709;&#x6743;&#x6700;&#x77ED;&#x8DEF;" class="plugin-anchor" href="#1dijkstra-&#x7B97;&#x6CD5;--&#x5355;&#x6E90;&#x6709;&#x6743;&#x6700;&#x77ED;&#x8DEF;"><i class="fa fa-link" aria-hidden="true"></i></a>1.Dijkstra &#x7B97;&#x6CD5;  &#x5355;&#x6E90;&#x6709;&#x6743;&#x6700;&#x77ED;&#x8DEF;</h3>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201128113037.png" alt="image-20201128113037591"></p>
<ul>
<li>&#x4EE4; S = {&#x6E90;&#x70B9;s + &#x5DF2;&#x7ECF;&#x786E;&#x5B9A;&#x4E86;&#x6700;&#x77ED;&#x8DEF;&#x5F84;&#x7684;&#x9876;&#x70B9; vi _i<em>i</em>}</li>
<li>&#x5BF9;&#x4EFB;&#x4E00;&#x672A;&#x6536;&#x5F55;&#x7684;&#x9876;&#x70B9; v&#xFF0C;&#x5B9A;&#x4E49; dist[v] &#x4E3A; s &#x5230; v &#x7684;&#x6700;&#x77ED;&#x8DEF;&#x5F84;&#x957F;&#x5EA6;&#xFF0C;&#x4F46;&#x8BE5;&#x8DEF;&#x5F84;&#x4EC5;&#x7ECF;&#x8FC7; S &#x4E2D;&#x7684;&#x9876;&#x70B9;&#x3002;&#x5373;&#x8DEF;&#x5F84; {s&#x2192;(vi _i<em>i</em>&#x2208;S)&#x2192;v} &#x7684;&#x6700;&#x5C0F;&#x957F;&#x5EA6;</li>
<li>&#x82E5;&#x8DEF;&#x5F84;&#x662F;&#x6309;&#x7167;&#x9012;&#x589E;&#xFF08;&#x975E;&#x9012;&#x51CF;&#xFF09;&#x7684;&#x987A;&#x5E8F;&#x751F;&#x6210;&#x7684;&#xFF0C;&#x5219;<ul>
<li>&#x771F;&#x6B63;&#x7684;&#x6700;&#x77ED;&#x8DEF;&#x5FC5;&#x987B;&#x53EA;&#x7ECF;&#x8FC7; S &#x4E2D;&#x7684;&#x9876;&#x70B9;</li>
<li>&#x6BCF;&#x6B21;&#x4ECE;&#x672A;&#x6536;&#x5F55;&#x7684;&#x9876;&#x70B9;&#x4E2D;&#x9009;&#x4E00;&#x4E2A; dist &#x6700;&#x5C0F;&#x7684;&#x6536;&#x5F55;</li>
<li>&#x589E;&#x52A0;&#x4E00;&#x4E2A; v &#x8FDB;&#x5165; S&#xFF0C;&#x53EF;&#x80FD;&#x5F71;&#x54CD;&#x53E6;&#x5916;&#x4E00;&#x4E2A; w &#x7684; dist &#x503C;<ul>
<li>dist[w] = min{dist[w],dist[v] + <v,w>&#x7684;&#x6743;&#x91CD;}</v,w></li>
</ul>
</li>
</ul>
</li>
</ul>
<p>&#x4F2A;&#x4EE3;&#x7801;:</p>
<pre><code>void Dijkstra( Vertex s ){
    while(1){
        V = &#x672A;&#x6536;&#x5F55;&#x9876;&#x70B9;&#x4E2D;dist&#x6700;&#x5C0F;&#x503C;;
        if( &#x8FD9;&#x6837;&#x7684;V&#x4E0D;&#x5B58;&#x5728; )
            break;
        collected[V] = true;
        for( V &#x7684;&#x6BCF;&#x4E2A;&#x90BB;&#x63A5;&#x70B9; W )
            if( collected[W] == false )
                if(dist[V] + E&lt;V,W&gt; &lt; dist[W]){
                     dist[W] = dist[V] + E&lt;V,W&gt;;
                    path[W] = V;
                }
    }
}
</code></pre><p>&#x5806;&#x4F18;&#x5316;&#x7248;&#x7B97;&#x6CD5;&#x6A21;&#x677F;:(heap&#x4E2D;&#x7684;&#x81EA;&#x52A8;&#x6392;&#x5E8F;:&#x5148;&#x5BF9;&#x7B2C;&#x4E00;&#x4E2A;&#x4ECE;&#x5C0F;&#x5230;&#x5927;&#x6392;&#x5E8F;,&#x82E5;&#x7B2C;&#x4E00;&#x4E2A;&#x76F8;&#x7B49;,&#x5BF9;&#x7B2C;&#x4E8C;&#x4E2A;&#x4ECE;&#x5C0F;&#x5230;&#x5927;&#x6392;&#x5E8F;)</p>
<pre><code>    int dijkstra(vector&lt;vector&lt;int&gt;&gt;&amp; gh, int N, int K) {
        const int INF = 0x3f3f3f3f;
        typedef pair&lt;int, int&gt; PII; // first:&#x8DDD;&#x79BB;; second: &#x51E0;&#x53F7;&#x70B9;
        vector&lt;bool&gt; vis(N + 1, false); // &#x662F;&#x5426;&#x5DF2;&#x5F97;&#x5230;&#x6700;&#x77ED;&#x8DDD;&#x79BB;
        vector&lt;int&gt; dist(N+1, INF); // &#x8DDD;&#x79BB;&#x8D77;&#x59CB;&#x70B9;&#x7684;&#x6700;&#x77ED;&#x8DDD;&#x79BB;
        unordered_map&lt;int, vector&lt;PII&gt;&gt; graph; // &#x90BB;&#x63A5;&#x8868;&#xFF1B;u-&gt;v,&#x6743;&#x91CD;w
        priority_queue&lt;PII, vector&lt;PII&gt;, greater&lt;PII&gt;&gt; heap; // &#x5C0F;&#x9876;&#x5806;&#xFF1B;&#x7EF4;&#x62A4;&#x5230;&#x8D77;&#x59CB;&#x70B9;&#x7684;&#x6700;&#x77ED;&#x8DDD;&#x79BB;&#x548C;&#x70B9;

        for (auto &amp;t: gh){ // &#x521D;&#x59CB;&#x5316;&#x90BB;&#x63A5;&#x8868;
            graph[t[0]].push_back({t[2],t[1]});
        }

        heap.push({0, K});
        dist[K] = 0;
        while(heap.size()){
            auto t = heap.top();
            heap.pop();
            int ver = t.second, distance = t.first;
            if (vis[ver]) continue; // &#x4E4B;&#x524D;&#x66F4;&#x65B0;&#x8FC7;&#xFF0C;&#x662F;&#x5197;&#x4F59;&#x5907;&#x4EFD;
            vis[ver] = true;
            for (auto &amp;p: graph[ver]){
                if (dist[p.second] &gt; distance + p.first){ // &#x7528;t&#x53BB;&#x66F4;&#x65B0;&#x5176;&#x4ED6;&#x70B9;&#x5230;&#x8D77;&#x59CB;&#x70B9;&#x7684;&#x6700;&#x77ED;&#x8DDD;&#x79BB;
                    dist[p.second] = distance + p.first;
                    heap.push({dist[p.second], p.second});
                }
            }
        }
        int ans = *max_element(dist.begin()+1, dist.end());
        return ans == INF ? -1: ans;
    }
</code></pre><h3 id="2floyd&#x7B97;&#x6CD5;--&#x591A;&#x6E90;&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;"><a name="2floyd&#x7B97;&#x6CD5;--&#x591A;&#x6E90;&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#2floyd&#x7B97;&#x6CD5;--&#x591A;&#x6E90;&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2floyd&#x7B97;&#x6CD5;--&#x591A;&#x6E90;&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;" class="plugin-anchor" href="#2floyd&#x7B97;&#x6CD5;--&#x591A;&#x6E90;&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>2.Floyd&#x7B97;&#x6CD5;  &#x591A;&#x6E90;&#x6700;&#x77ED;&#x8DEF;&#x7B97;&#x6CD5;</h3>
<p>&#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x52A8;&#x6001;&#x89C4;&#x5212;&#x7684;&#x601D;&#x60F3;:</p>
<pre><code>void Floyd(){
    for( k = 0; k &lt; N; k++ )
        for( i = 0; i&lt; N; i++)
            for( j = 0; j &lt; N; j++ )
                if( D[i][k] + D[k][j] &lt; D[i][j] ) {
                    D[i][j] = D[i][k] + D[k][j];
                    path[i][j] = k;
                }
}
</code></pre><p>&#x7B97;&#x6CD5;&#x6A21;&#x677F;:</p>
<pre><code>    int floyd(vector&lt;vector&lt;int&gt;&gt;&amp; gh, int N, int K) {
        const int INF = 0x3f3f3f3f;
        vector&lt;vector&lt;int&gt;&gt; dist(N+1,vector&lt;int&gt;(N+1,INF));
        for (int i = 0; i &lt;=N ; ++i) {
            dist[i][i]=0;
        }
        for(auto k:gh){
            dist[k[0]][k[1]]=min(dist[k[0]][k[1]],k[2]);
        }
        for (int k = 1; k &lt;=N ; ++k) {
            for (int i = 1; i &lt;=N ; ++i) {
                for (int j = 1; j &lt;=N ; ++j) {
                    dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
                }
            }
        }
        int ans=0;
        for (int l = 1; l &lt;=N ; ++l) {
            ans=max(ans,dist[K][l]);
        }
        return ans&gt; INF/2?-1:ans;
    }
</code></pre><h2 id="&#x4E09;-&#x5E76;&#x67E5;&#x96C6;"><a name="&#x4E09;-&#x5E76;&#x67E5;&#x96C6;" class="anchor-navigation-ex-anchor" href="#&#x4E09;-&#x5E76;&#x67E5;&#x96C6;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E09;-&#x5E76;&#x67E5;&#x96C6;" class="plugin-anchor" href="#&#x4E09;-&#x5E76;&#x67E5;&#x96C6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E09; &#x5E76;&#x67E5;&#x96C6;</h2>
<h3 id="1&#x5B9A;&#x4E49;"><a name="1&#x5B9A;&#x4E49;" class="anchor-navigation-ex-anchor" href="#1&#x5B9A;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x5B9A;&#x4E49;" class="plugin-anchor" href="#1&#x5B9A;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>1.&#x5B9A;&#x4E49;</h3>
<p>&#x5982;&#x4E0B;&#x9762;&#x8FD9;&#x5E45;&#x56FE;&#xFF0C;&#x603B;&#x5171;&#x6709; 10 &#x4E2A;&#x8282;&#x70B9;&#xFF0C;&#x4ED6;&#x4EEC;&#x4E92;&#x4E0D;&#x76F8;&#x8FDE;&#xFF0C;&#x5206;&#x522B;&#x7528; 0~9 &#x6807;&#x8BB0;&#xFF1A;</p>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201128114607.png" alt="image-20201128114606903"></p>
<p>&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x7684; Union-Find &#x7B97;&#x6CD5;&#x4E3B;&#x8981;&#x9700;&#x8981;&#x5B9E;&#x73B0;&#x8FD9;&#x4E24;&#x4E2A; API&#xFF1A;</p>
<pre><code>class UF {
    /* &#x5C06; p &#x548C; q &#x8FDE;&#x63A5; */
    public void union(int p, int q);
    /* &#x5224;&#x65AD; p &#x548C; q &#x662F;&#x5426;&#x8FDE;&#x901A; */
    public boolean connected(int p, int q);
    /* &#x8FD4;&#x56DE;&#x56FE;&#x4E2D;&#x6709;&#x591A;&#x5C11;&#x4E2A;&#x8FDE;&#x901A;&#x5206;&#x91CF; */
    public int count();
}
</code></pre><p>&#x8FD9;&#x91CC;&#x6240;&#x8BF4;&#x7684;&#x300C;&#x8FDE;&#x901A;&#x300D;&#x662F;&#x4E00;&#x79CD;&#x7B49;&#x4EF7;&#x5173;&#x7CFB;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x5177;&#x6709;&#x5982;&#x4E0B;&#x4E09;&#x4E2A;&#x6027;&#x8D28;&#xFF1A;</p>
<p>1&#x3001;&#x81EA;&#x53CD;&#x6027;&#xFF1A;&#x8282;&#x70B9;<code>p</code>&#x548C;<code>p</code>&#x662F;&#x8FDE;&#x901A;&#x7684;&#x3002;</p>
<p>2&#x3001;&#x5BF9;&#x79F0;&#x6027;&#xFF1A;&#x5982;&#x679C;&#x8282;&#x70B9;<code>p</code>&#x548C;<code>q</code>&#x8FDE;&#x901A;&#xFF0C;&#x90A3;&#x4E48;<code>q</code>&#x548C;<code>p</code>&#x4E5F;&#x8FDE;&#x901A;&#x3002;</p>
<p>3&#x3001;&#x4F20;&#x9012;&#x6027;&#xFF1A;&#x5982;&#x679C;&#x8282;&#x70B9;<code>p</code>&#x548C;<code>q</code>&#x8FDE;&#x901A;&#xFF0C;<code>q</code>&#x548C;<code>r</code>&#x8FDE;&#x901A;&#xFF0C;&#x90A3;&#x4E48;<code>p</code>&#x548C;<code>r</code>&#x4E5F;&#x8FDE;&#x901A;&#x3002;</p>
<p>&#x6BD4;&#x5982;&#x8BF4;&#x4E4B;&#x524D;&#x90A3;&#x5E45;&#x56FE;&#xFF0C;0&#xFF5E;9 &#x4EFB;&#x610F;&#x4E24;&#x4E2A;<strong>&#x4E0D;&#x540C;</strong>&#x7684;&#x70B9;&#x90FD;&#x4E0D;&#x8FDE;&#x901A;&#xFF0C;&#x8C03;&#x7528;<code>connected</code>&#x90FD;&#x4F1A;&#x8FD4;&#x56DE; false&#xFF0C;&#x8FDE;&#x901A;&#x5206;&#x91CF;&#x4E3A; 10 &#x4E2A;&#x3002;</p>
<p>&#x5982;&#x679C;&#x73B0;&#x5728;&#x8C03;&#x7528;<code>union(0, 1)</code>&#xFF0C;&#x90A3;&#x4E48; 0 &#x548C; 1 &#x88AB;&#x8FDE;&#x901A;&#xFF0C;&#x8FDE;&#x901A;&#x5206;&#x91CF;&#x964D;&#x4E3A; 9 &#x4E2A;&#x3002;</p>
<p>&#x518D;&#x8C03;&#x7528;<code>union(1, 2)</code>&#xFF0C;&#x8FD9;&#x65F6; 0,1,2 &#x90FD;&#x88AB;&#x8FDE;&#x901A;&#xFF0C;&#x8C03;&#x7528;<code>connected(0, 2)</code>&#x4E5F;&#x4F1A;&#x8FD4;&#x56DE; true&#xFF0C;&#x8FDE;&#x901A;&#x5206;&#x91CF;&#x53D8;&#x4E3A; 8 &#x4E2A;&#x3002;</p>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201128114644.png" alt="image-20201128114643714"></p>
<p>&#x5982;&#x679C;&#x67D0;&#x4E24;&#x4E2A;&#x8282;&#x70B9;&#x88AB;&#x8FDE;&#x901A;&#xFF0C;&#x5219;&#x8BA9;&#x5176;&#x4E2D;&#x7684;&#xFF08;&#x4EFB;&#x610F;&#xFF09;&#x4E00;&#x4E2A;&#x8282;&#x70B9;&#x7684;&#x6839;&#x8282;&#x70B9;&#x63A5;&#x5230;&#x53E6;&#x4E00;&#x4E2A;&#x8282;&#x70B9;&#x7684;&#x6839;&#x8282;&#x70B9;&#x4E0A;:</p>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201128114730.png" alt="image-20201128114730305"></p>
<h3 id="2&#x6A21;&#x677F;"><a name="2&#x6A21;&#x677F;" class="anchor-navigation-ex-anchor" href="#2&#x6A21;&#x677F;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2&#x6A21;&#x677F;" class="plugin-anchor" href="#2&#x6A21;&#x677F;"><i class="fa fa-link" aria-hidden="true"></i></a>2.&#x6A21;&#x677F;</h3>
<pre><code>class UnionFind{
public:
    int UnionNums;
    int *graph;
    /**
     * find
     */
    int find(int k){
        if(graph[k]==k)return k;
        else return k=find(graph[k]);
    }
    /**
     * union
     */
    void Union(int i,int j){
        int pI=find(i);
        int pK=find(j);
        if(pI!=pK){
            graph[pK]=pI;
            UnionNums--;
        }
    }

    //&#x521D;&#x59CB;&#x5316;
    UnionFind(int nums){
        UnionNums=nums;
        graph=new int[nums+1];
        for(int i=0;i&lt;=nums;i++){
            graph[i]=i;
        }
    }
};
</code></pre><h2 id="&#x56DB;-&#x62D3;&#x6251;&#x6392;&#x5E8F;"><a name="&#x56DB;-&#x62D3;&#x6251;&#x6392;&#x5E8F;" class="anchor-navigation-ex-anchor" href="#&#x56DB;-&#x62D3;&#x6251;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x56DB;-&#x62D3;&#x6251;&#x6392;&#x5E8F;" class="plugin-anchor" href="#&#x56DB;-&#x62D3;&#x6251;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x56DB; &#x62D3;&#x6251;&#x6392;&#x5E8F;</h2>
<h3 id="1&#x5B9A;&#x4E49;_1"><a name="1&#x5B9A;&#x4E49;_1" class="anchor-navigation-ex-anchor" href="#1&#x5B9A;&#x4E49;_1"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x5B9A;&#x4E49;" class="plugin-anchor" href="#1&#x5B9A;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>1.&#x5B9A;&#x4E49;</h3>
<p>&#x4E00;&#x5171;&#x6709; n &#x95E8;&#x8BFE;&#x8981;&#x4E0A;&#xFF0C;&#x7F16;&#x53F7;&#x4E3A;0 ~ n-1&#x3002;&#x5148;&#x51B3;&#x6761;&#x4EF6;[1, 0]&#xFF0C;&#x4EE3;&#x8868;&#x5FC5;&#x987B;&#x5148;&#x4E0A;&#x8BFE; 0&#xFF0C;&#x624D;&#x80FD;&#x4E0A;&#x8BFE; 1 &#x3002;&#x7ED9;&#x4F60; n &#x548C;&#x4E00;&#x4E2A;&#x5148;&#x51B3;&#x6761;&#x4EF6;&#x8868;&#xFF0C;&#x8BF7;&#x4F60;&#x5224;&#x65AD;&#x80FD;&#x5426;&#x5B8C;&#x6210;&#x6240;&#x6709;&#x8BFE;&#x7A0B;</p>
<p>&#x751F;&#x6D3B;&#x7684;&#x4F8B;&#x5B50;</p>
<ul>
<li>&#x5148;&#x7A7F;&#x5185;&#x88E4;&#x518D;&#x7A7F;&#x88E4;&#x5B50;&#xFF0C;&#x5148;&#x7A7F;&#x6253;&#x5E95;&#x518D;&#x7A7F;&#x5916;&#x5957;&#xFF0C;&#x5148;&#x7A7F;&#x8863;&#x670D;&#x518D;&#x6234;&#x5E3D;&#x5B50;&#xFF0C;&#x7EA6;&#x5B9A;&#x4FD7;&#x6210;</li>
<li>&#x5185;&#x88E4;&#x5916;&#x7A7F;&#x3001;&#x5149;&#x7740;&#x8EAB;&#x5B50;&#x6234;&#x5E3D;&#x7B49;&#xFF0C;&#x90FD;&#x4F1A;&#x6709;&#x70B9;&#x5947;&#x602A;</li>
<li>&#x7EA6;&#x675F;&#x6211;&#x4EEC;&#x7684;&#x4E00;&#x6761;&#x6761; &#x5148;&#x540E;&#x89C4;&#x5219;&#xFF0C;&#x80FD;&#x5426;&#x8F6C;&#x6210;&#x4E00;&#x4E32;&#x987A;&#x5E8F;&#x884C;&#x4E3A;&#x2014;&#x2014;&#x8863;&#x670D;&#x662F;&#x4E00;&#x4EF6;&#x4EF6;&#x7A7F;&#x7684;</li>
</ul>
<p>&#x5F15;&#x5165;&#x6709;&#x5411;&#x56FE; &#x63CF;&#x8FF0;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;
&#x793A;&#x4F8B;&#xFF1A;n = 6&#xFF0C;&#x5148;&#x51B3;&#x6761;&#x4EF6;&#x8868;&#xFF1A;[ [3, 0], [3, 1], [4, 1], [4, 2], [5, 3], [5, 4] ]
0, 1, 2 &#x6CA1;&#x6709;&#x5148;&#x4FEE;&#x8BFE;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x9009;&#x3002;&#x5176;&#x4F59;&#x7684;&#xFF0C;&#x90FD;&#x8981;&#x5148;&#x4FEE; 2 &#x95E8;&#x8BFE;
&#x6211;&#x4EEC;&#x7528; &#x6709;&#x5411;&#x56FE; &#x63CF;&#x8FF0;&#x8FD9;&#x79CD; &#x4F9D;&#x8D56;&#x5173;&#x7CFB; (&#x505A;&#x4E8B;&#x7684;&#x5148;&#x540E;&#x5173;&#x7CFB;)&#xFF1A;</p>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201128113430.png" alt="&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20200517052852.png"></p>
<ul>
<li>&#x628A;&#x8FD9;&#x6837;&#x4E00;&#x4E2A; &#x6709;&#x5411;&#x65E0;&#x73AF;&#x56FE; &#x53D8;&#x6210; &#x7EBF;&#x6027;&#x7684;&#x6392;&#x5E8F; &#x5C31;&#x53EB; &#x62D3;&#x6251;&#x6392;&#x5E8F;</li>
<li>&#x6709;&#x5411;&#x56FE; &#x4E2D;&#x6709; &#x5165;&#x5EA6; &#x548C; &#x51FA;&#x5EA6; &#x6982;&#x5FF5;&#xFF1A;</li>
<li>&#x5982;&#x679C;&#x5B58;&#x5728;&#x4E00;&#x6761;&#x6709;&#x5411;&#x8FB9; A --&gt; B&#xFF0C;&#x5219;&#x8FD9;&#x6761;&#x8FB9;&#x7ED9; A &#x589E;&#x52A0;&#x4E86; 1 &#x4E2A;&#x51FA;&#x5EA6;&#xFF0C;&#x7ED9; B &#x589E;&#x52A0;&#x4E86; 1 &#x4E2A;&#x5165;&#x5EA6;</li>
</ul>
<p>&#x6240;&#x4EE5;&#x9876;&#x70B9; 0&#x3001;1&#x3001;2 &#x7684; &#x5165;&#x5EA6;&#x4E3A; 0&#x3002; &#x9876;&#x70B9; 3&#x3001;4&#x3001;5 &#x7684; &#x5165;&#x5EA6;&#x4E3A; 2</p>
<p>&#x89E3;&#x51B3;&#x95EE;&#x9898;&#x7684;&#x5173;&#x952E;:</p>
<p>0.&#x987A;&#x5E8F;&#x662F;&#x4EC0;&#x4E48;?</p>
<p>1.&#x5BF9;&#x4E8E;&#x4EC0;&#x4E48;&#x6765;&#x8BF4;&#x662F;&#x6709;&#x5165;&#x5EA6;&#x7684;,&#x4EC0;&#x4E48;&#x662F;&#x51FA;&#x5EA6;</p>
<p>2.&#x6BCF;&#x6B21;&#x53EA;&#x80FD;&#x9009;&#x5165;&#x8BFB;&#x4E3A;0&#x7684;&#x8BFE;&#x8FDB;&#x884C;&#x6536;&#x5F55;</p>
<p>3.&#x5230;&#x6700;&#x540E;&#x5982;&#x679C;&#x8FD8;&#x6709;&#x4E00;&#x4E2A;&#x8BFE;&#x7684;&#x5165;&#x8BFB;&#x4E0D;&#x4E3A;0,&#x5219;&#x8BF4;&#x660E;&#x5B58;&#x5728;&#x73AF;&#x5F62;&#x56FE;</p>
<h3 id="2&#x6A21;&#x677F;_1"><a name="2&#x6A21;&#x677F;_1" class="anchor-navigation-ex-anchor" href="#2&#x6A21;&#x677F;_1"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2&#x6A21;&#x677F;" class="plugin-anchor" href="#2&#x6A21;&#x677F;"><i class="fa fa-link" aria-hidden="true"></i></a>2.&#x6A21;&#x677F;:</h3>
<p>&#x4EE5;&#x4E0A;&#x9762;&#x63D0;&#x5230;&#x7684;&#x8BFE;&#x7A0B;&#x8868;&#x4E3A;&#x4F8B;&#x5B50;:</p>
<p>&#x4F60;&#x8FD9;&#x4E2A;&#x5B66;&#x671F;&#x5FC5;&#x987B;&#x9009;&#x4FEE; numCourse &#x95E8;&#x8BFE;&#x7A0B;&#xFF0C;&#x8BB0;&#x4E3A; 0 &#x5230; numCourse-1 &#x3002;</p>
<p>&#x5728;&#x9009;&#x4FEE;&#x67D0;&#x4E9B;&#x8BFE;&#x7A0B;&#x4E4B;&#x524D;&#x9700;&#x8981;&#x4E00;&#x4E9B;&#x5148;&#x4FEE;&#x8BFE;&#x7A0B;&#x3002; &#x4F8B;&#x5982;&#xFF0C;&#x60F3;&#x8981;&#x5B66;&#x4E60;&#x8BFE;&#x7A0B; 0 &#xFF0C;&#x4F60;&#x9700;&#x8981;&#x5148;&#x5B8C;&#x6210;&#x8BFE;&#x7A0B; 1 &#xFF0C;&#x6211;&#x4EEC;&#x7528;&#x4E00;&#x4E2A;&#x5339;&#x914D;&#x6765;&#x8868;&#x793A;&#x4ED6;&#x4EEC;&#xFF1A;[0,1]</p>
<p>&#x7ED9;&#x5B9A;&#x8BFE;&#x7A0B;&#x603B;&#x91CF;&#x4EE5;&#x53CA;&#x5B83;&#x4EEC;&#x7684;&#x5148;&#x51B3;&#x6761;&#x4EF6;&#xFF0C;&#x8BF7;&#x4F60;&#x5224;&#x65AD;&#x662F;&#x5426;&#x53EF;&#x80FD;&#x5B8C;&#x6210;&#x6240;&#x6709;&#x8BFE;&#x7A0B;&#x7684;&#x5B66;&#x4E60;&#xFF1F;</p>
<p> <img src="https://gitee.com/zisuu/picture/raw/master/img/20201128113531.png" alt="59410727664"></p>
<pre><code>class Solution {
public:
    bool canFinish(int numCourses, vector&lt;vector&lt;int&gt;&gt;&amp; prerequisites) {
     int len=numCourses;
     int in[len];
     int out[len];
     vector&lt;vector&lt;int&gt;&gt; ve;
     queue&lt;int&gt; q;
     vector&lt;int&gt; v;
     for(int i=0;i&lt;len;i++){
         in[i]=out[i]=0;
         ve.push_back(v);
     }

     //&#x6784;&#x5EFA;&#x62D3;&#x6251;&#x5E8F;&#x5217;
     for(int i=0;i&lt;prerequisites.size();i++){
         int l1=prerequisites[i][0];
         int l2=prerequisites[i][1];
         ve[l2].push_back(l1);
         in[l1]++;
     }
     //&#x5C06;&#x5165;&#x5EA6;&#x4E3A;0&#x7684;&#x653E;&#x5165;&#x961F;&#x5217;
     for(int i=0;i&lt;len;i++){
         if(in[i]==0)q.push(i);
     }
     int cnt=0;
     while(!q.empty()){
         int cur=q.front();
         q.pop();
         cnt++;
         //&#x904D;&#x5386;&#x5F53;&#x524D;&#x8282;&#x70B9;&#x7684;&#x90BB;&#x63A5;&#x8868;
         for(int i=0;i&lt;ve[cur].size();i++){
             int c=ve[cur][i];
             in[c]--;
             if(in[c]==0)q.push(ve[cur][i]);
         }
     }
     return cnt==len;
}
};
</code></pre><h2 id="&#x4E94;-&#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;"><a name="&#x4E94;-&#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;" class="anchor-navigation-ex-anchor" href="#&#x4E94;-&#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E94;-&#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;" class="plugin-anchor" href="#&#x4E94;-&#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E94; &#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;</h2>
<h3 id="0&#x5B9A;&#x4E49;"><a name="0&#x5B9A;&#x4E49;" class="anchor-navigation-ex-anchor" href="#0&#x5B9A;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="0&#x5B9A;&#x4E49;" class="plugin-anchor" href="#0&#x5B9A;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>0.&#x5B9A;&#x4E49;</h3>
<ul>
<li><strong>&#x8FDE;&#x901A;&#x7F51;</strong>&#xFF1A;&#x5728;&#x8FDE;&#x901A;&#x56FE;&#x4E2D;&#xFF0C;&#x82E5;&#x56FE;&#x7684;&#x8FB9;&#x5177;&#x6709;&#x4E00;&#x5B9A;&#x7684;&#x610F;&#x4E49;&#xFF0C;&#x6BCF;&#x4E00;&#x6761;&#x8FB9;&#x90FD;&#x5BF9;&#x5E94;&#x7740;&#x4E00;&#x4E2A;&#x6570;&#xFF0C;&#x79F0;&#x4E3A;&#x6743;&#xFF1B;&#x6743;&#x4EE3;&#x8868;&#x7740;&#x8FDE;&#x63A5;&#x8FDE;&#x4E2A;&#x9876;&#x70B9;&#x7684;&#x4EE3;&#x4EF7;&#xFF0C;&#x79F0;&#x8FD9;&#x79CD;&#x8FDE;&#x901A;&#x56FE;&#x53EB;&#x505A;&#x8FDE;&#x901A;&#x7F51;&#x3002;</li>
<li><strong>&#x751F;&#x6210;&#x6811;</strong>&#xFF1A;&#x4E00;&#x4E2A;&#x8FDE;&#x901A;&#x56FE;&#x7684;&#x751F;&#x6210;&#x6811;&#x662F;&#x6307;&#x4E00;&#x4E2A;&#x8FDE;&#x901A;&#x5B50;&#x56FE;&#xFF0C;&#x5B83;&#x542B;&#x6709;&#x56FE;&#x4E2D;&#x5168;&#x90E8;n&#x4E2A;&#x9876;&#x70B9;&#xFF0C;&#x4F46;&#x53EA;&#x6709;&#x8DB3;&#x4EE5;&#x6784;&#x6210;&#x4E00;&#x68F5;&#x6811;&#x7684;n-1&#x6761;&#x8FB9;&#x3002;&#x4E00;&#x9897;&#x6709;n&#x4E2A;&#x9876;&#x70B9;&#x7684;&#x751F;&#x6210;&#x6811;&#x6709;&#x4E14;&#x4EC5;&#x6709;n-1&#x6761;&#x8FB9;&#xFF0C;&#x5982;&#x679C;&#x751F;&#x6210;&#x6811;&#x4E2D;&#x518D;&#x6DFB;&#x52A0;&#x4E00;&#x6761;&#x8FB9;&#xFF0C;&#x5219;&#x5FC5;&#x5B9A;&#x6210;&#x73AF;&#x3002;</li>
<li><strong>&#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;</strong>&#xFF1A;&#x5728;&#x8FDE;&#x901A;&#x7F51;&#x7684;&#x6240;&#x6709;&#x751F;&#x6210;&#x6811;&#x4E2D;&#xFF0C;&#x6240;&#x6709;&#x8FB9;&#x7684;&#x4EE3;&#x4EF7;&#x548C;&#x6700;&#x5C0F;&#x7684;&#x751F;&#x6210;&#x6811;&#xFF0C;&#x79F0;&#x4E3A;&#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;&#x3002; 
<img src="https://gitee.com/zisuu/picture/raw/master/img/20201128114949.png" alt="&#x8FD9;&#x91CC;&#x5199;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></li>
</ul>
<h3 id="1prim&#x7B97;&#x6CD5;"><a name="1prim&#x7B97;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#1prim&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1prim&#x7B97;&#x6CD5;" class="plugin-anchor" href="#1prim&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.Prim&#x7B97;&#x6CD5;</h3>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201126142710.gif" alt="img"></p>
<p>&#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;:</p>
<blockquote>
<p>Prim&#x7B97;&#x6CD5;&#x5FAA;&#x73AF;|V|-1&#x2223;V&#x2223;&#x2212;1&#x6B21;, &#x4F7F;&#x7528;&#x7EBF;&#x6027;&#x626B;&#x63CF;&#x7B97;&#x6CD5;&#x5BFB;&#x627E;&#x6700;&#x5C0F;&#x503C;&#x7684;&#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;&#x4E3A;O(|V|^2+|E|), </p>
<p>&#x4F7F;&#x7528;&#x5806;&#x4F18;&#x5316;&#x7248;Prim&#x7B97;&#x6CD5;&#x7684;&#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;&#x662F;O(|E|log|V|)O(&#x2223;E&#x2223;log&#x2223;V&#x2223;).</p>
</blockquote>
<p><strong>&#x7B97;&#x6CD5;&#x6A21;&#x677F;:</strong>(&#x5806;&#x4F18;&#x5316;)</p>
<pre><code class="lang-c++"><span class="hljs-keyword">typedef</span> pair&lt;<span class="hljs-keyword">int</span>,<span class="hljs-keyword">int</span>&gt; ll;
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">prim</span><span class="hljs-params">( <span class="hljs-built_in">vector</span>&lt;<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&gt; graph, <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; dist,<span class="hljs-keyword">int</span> n)</span></span>{
    priority_queue&lt;ll,<span class="hljs-built_in">vector</span>&lt;ll&gt;,greater&lt;ll&gt;&gt; q;
    <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">bool</span>&gt; vis(n+<span class="hljs-number">1</span>, <span class="hljs-literal">false</span>);
    dist[<span class="hljs-number">1</span>]=<span class="hljs-number">0</span>;
    <span class="hljs-keyword">int</span> sum=<span class="hljs-number">0</span>;
    q.push({dist[<span class="hljs-number">1</span>],<span class="hljs-number">1</span>});
    <span class="hljs-keyword">while</span>( !q.empty() ){
        <span class="hljs-keyword">int</span> index=q.top().second;
        q.pop();
        <span class="hljs-keyword">if</span>(vis[index])<span class="hljs-keyword">continue</span>;
        <span class="hljs-meta">#&#x52A0;&#x4E0A;&#x8FD9;&#x6761;&#x8FB9;</span>
        sum+=dist[index];
        vis[index]= <span class="hljs-literal">true</span>;
        <span class="hljs-meta">#&#x5BF9;&#x5176;&#x90BB;&#x63A5;&#x8FB9;,&#x6536;&#x5F55;</span>
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">1</span>; i &lt;=n ; ++i) {
            <span class="hljs-keyword">if</span>(!vis[i] &amp;&amp; graph[index][i]&lt;dist[i] ){
                dist[i]=graph[index][i];
                q.push({dist[i],i});
            }
        }
    }
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">1</span>; i &lt;= n ; ++i) {
        <span class="hljs-keyword">if</span>(!vis[i])<span class="hljs-keyword">return</span> <span class="hljs-number">-1</span>;
    }
    <span class="hljs-keyword">return</span> sum;
}
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span>{
    <span class="hljs-keyword">int</span> n,m;
    <span class="hljs-built_in">cin</span>&gt;&gt;n&gt;&gt;m;
    <span class="hljs-keyword">int</span> inf=<span class="hljs-number">10000000</span>;
    <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; dist(n+<span class="hljs-number">1</span>,inf);
    <span class="hljs-built_in">vector</span>&lt;<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&gt; graph(n+<span class="hljs-number">1</span>,<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;(n+<span class="hljs-number">1</span>,inf));
    <span class="hljs-keyword">int</span> a,b,value;
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span>;i&lt;m;i++){
        <span class="hljs-built_in">cin</span>&gt;&gt;a&gt;&gt;b&gt;&gt;value;
        graph[a][b]=value;
        graph[b][a]=value;
    }
    <span class="hljs-built_in">cout</span>&lt;&lt;prim(graph,dist,n);
}
</code></pre>
<h3 id="2kruskal-&#x7B97;&#x6CD5;"><a name="2kruskal-&#x7B97;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#2kruskal-&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2kruskal-&#x7B97;&#x6CD5;" class="plugin-anchor" href="#2kruskal-&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>2.Kruskal &#x7B97;&#x6CD5;</h3>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201126145815.gif" alt="img"></p>
<blockquote>
<p>Kruskal&#x7B97;&#x6CD5;&#x662F;&#x7528;&#x4E8E;&#x751F;&#x6210;&#x65E0;&#x5411;&#x5E26;&#x6743;&#x8FDE;&#x901A;&#x56FE;&#x7684;&#x6700;&#x5C0F;&#x751F;&#x6210;&#x6811;&#x7684;&#x7B97;&#x6CD5;, &#x5728;Kruskal&#x7B97;&#x6CD5;&#x4E2D;&#x5C06;&#x56FE;&#x4E2D;&#x6BCF;&#x4E2A;&#x9876;&#x70B9;&#x770B;&#x505A;&#x4E00;&#x4E2A;&#x72EC;&#x7ACB;&#x7684;&#x96C6;&#x5408;, &#x9996;&#x5148;&#x5C06;&#x56FE;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x8FB9;&#x6309;&#x7167;&#x6743;&#x503C;&#x8FDB;&#x884C;&#x4ECE;&#x5C0F;&#x5230;&#x5927;&#x6392;&#x5E8F;, &#x5E76;&#x6309;&#x6B64;&#x987A;&#x5E8F;&#x679A;&#x4E3E;&#x6BCF;&#x6761;&#x8FB9;, &#x5982;&#x679C;&#x8FD9;&#x6761;&#x8FB9;&#x7684;&#x4E24;&#x4E2A;&#x7AEF;&#x70B9;&#x4E0D;&#x5C5E;&#x4E8E;&#x540C;&#x4E00;&#x4E2A;&#x96C6;&#x5408;(&#x8FDE;&#x901A;&#x5206;&#x91CF;), &#x90A3;&#x4E48;&#x5C06;&#x4E24;&#x4E2A;&#x96C6;&#x5408;&#x5408;&#x5E76;(&#x5E76;&#x67E5;&#x96C6;&#x7B97;&#x6CD5;), &#x540C;&#x65F6;&#x5C06;&#x8FD9;&#x6761;&#x8FB9;&#x52A0;&#x5165;&#x8FB9;&#x96C6;&#x5408;E&apos;E 
, &#x76F4;&#x5230;&#x6240;&#x6709;&#x7684;&#x9876;&#x70B9;&#x90FD;&#x5C5E;&#x4E8E;&#x540C;&#x4E00;&#x4E2A;&#x96C6;&#x5408;&#x65F6;, E&apos;E 
&#x5C31;&#x662F;MST.
Kruskal&#x662F;&#x4E00;&#x79CD;&#x8D2A;&#x5FC3;&#x7B97;&#x6CD5;, &#x5BF9;&#x4E8E;&#x672A;&#x9009;&#x62E9;&#x7684;&#x8FB9;&#x6743;&#x6700;&#x5C0F;&#x7684;&#x8FB9;(u, v)(u,v), &#x5982;&#x679C;&#x52A0;&#x4E0A;&#x8FD9;&#x6761;&#x8FB9;&#x540E;&#x56FE;&#x4E2D;&#x51FA;&#x73B0;&#x4E86;&#x4E00;&#x4E2A;&#x73AF;, &#x5219;&#x4E0D;&#x7B26;&#x5408;&#x6811;&#x7684;&#x6027;&#x8D28;, &#x5219;&#x4E0D;&#x9009;&#x62E9;&#x8BE5;&#x8FB9;.</p>
</blockquote>
<p>&#x7B97;&#x6CD5;&#x6A21;&#x677F;: </p>
<pre><code class="lang-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;bits/stdc++.h&gt;</span></span>
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> <span class="hljs-built_in">std</span>;
<span class="hljs-keyword">struct</span> Edge{
    <span class="hljs-keyword">int</span> a,b,w;
    Edge(<span class="hljs-keyword">int</span> a,<span class="hljs-keyword">int</span> b ,<span class="hljs-keyword">int</span> w):a(a),b(b),w(w){}
    <span class="hljs-keyword">bool</span> <span class="hljs-keyword">operator</span> &lt; (Edge o)<span class="hljs-keyword">const</span>{
        <span class="hljs-keyword">return</span> w&lt;o.w;
    }
};
<span class="hljs-built_in">vector</span>&lt;Edge&gt; g;
<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; fa;
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">find</span><span class="hljs-params">(<span class="hljs-keyword">int</span> x)</span></span>{
    <span class="hljs-keyword">return</span> x==fa[x]?x:fa[x]=find(fa[x]);
}
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">kruskal</span><span class="hljs-params">(<span class="hljs-keyword">int</span> n)</span></span>{
    <span class="hljs-comment">//&#x5BF9;&#x8FB9;&#x8FDB;&#x884C;&#x6392;&#x5E8F;</span>
    sort(g.begin(),g.end());
    <span class="hljs-keyword">int</span> ans=<span class="hljs-number">0</span>;
    <span class="hljs-keyword">int</span> cnt=n;
    <span class="hljs-keyword">for</span>(Edge e:g){
        <span class="hljs-keyword">int</span> fax= find(e.a);
        <span class="hljs-keyword">int</span> fay= find(e.b);
        <span class="hljs-keyword">if</span>(fax!=fay){
            <span class="hljs-comment">//&#x8BA1;&#x6570;</span>
            cnt--;
            <span class="hljs-comment">//&#x5408;&#x5E76;</span>
            fa[fax]=fay;
            <span class="hljs-comment">//&#x52A0;&#x4E0A;&#x8FD9;&#x6761;&#x8FB9;&#x7684;&#x503C;</span>
            ans+=e.w;
        }
    }
    <span class="hljs-keyword">return</span> cnt==<span class="hljs-number">1</span>?ans:<span class="hljs-number">-1</span>;
}
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span>{
    <span class="hljs-keyword">int</span> n,m;
    <span class="hljs-built_in">cin</span>&gt;&gt;n&gt;&gt;m;
    <span class="hljs-keyword">int</span> a,b,value;
    fa=<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;(n+<span class="hljs-number">1</span>,<span class="hljs-number">0</span>);
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">1</span>; i &lt;=n ; ++i) {
        fa[i]=i;
    }
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span>;i&lt;m;i++){
        <span class="hljs-built_in">cin</span>&gt;&gt;a&gt;&gt;b&gt;&gt;value;
        g.push_back(Edge(a,b,value));
    }
    <span class="hljs-built_in">cout</span>&lt;&lt;kruskal(n);
}
</code></pre>
<h2 id="&#x516D;-&#x4E8C;&#x5206;&#x56FE;"><a name="&#x516D;-&#x4E8C;&#x5206;&#x56FE;" class="anchor-navigation-ex-anchor" href="#&#x516D;-&#x4E8C;&#x5206;&#x56FE;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x516D;-&#x4E8C;&#x5206;&#x56FE;" class="plugin-anchor" href="#&#x516D;-&#x4E8C;&#x5206;&#x56FE;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x516D; &#x4E8C;&#x5206;&#x56FE;</h2>
<h3 id="1&#x5B9A;&#x4E49;_2"><a name="1&#x5B9A;&#x4E49;_2" class="anchor-navigation-ex-anchor" href="#1&#x5B9A;&#x4E49;_2"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x5B9A;&#x4E49;" class="plugin-anchor" href="#1&#x5B9A;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>1.&#x5B9A;&#x4E49;</h3>
<p>&#x7ED9;&#x5B9A;&#x4E00;&#x4E2A;&#x4E8C;&#x5206;&#x56FE;G&#xFF0C;&#x5728;G&#x7684;&#x4E00;&#x4E2A;&#x5B50;&#x56FE;M&#x4E2D;&#xFF0C;M&#x7684;&#x8FB9;&#x96C6;{E}&#x4E2D;&#x7684;&#x4EFB;&#x610F;&#x4E24;&#x6761;&#x8FB9;&#x90FD;&#x4E0D;&#x4F9D;&#x9644;&#x4E8E;&#x540C;&#x4E00;&#x4E2A;&#x9876;&#x70B9;&#xFF0C;&#x5219;&#x79F0;M&#x662F;&#x4E00;&#x4E2A;&#x5339;&#x914D;&#x3002;&#x6781;&#x5927;&#x5339;&#x914D;(Maximal Matching)&#x662F;&#x6307;&#x5728;&#x5F53;&#x524D;&#x5DF2;&#x5B8C;&#x6210;&#x7684;&#x5339;&#x914D;&#x4E0B;,&#x65E0;&#x6CD5;&#x518D;&#x901A;&#x8FC7;&#x589E;&#x52A0;&#x672A;&#x5B8C;&#x6210;&#x5339;&#x914D;&#x7684;&#x8FB9;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x589E;&#x52A0;&#x5339;&#x914D;&#x7684;&#x8FB9;&#x6570;&#x3002;&#x6700;&#x5927;&#x5339;&#x914D;(maximum matching)&#x662F;&#x6240;&#x6709;&#x6781;&#x5927;&#x5339;&#x914D;&#x5F53;&#x4E2D;&#x8FB9;&#x6570;&#x6700;&#x5927;&#x7684;&#x4E00;&#x4E2A;&#x5339;&#x914D;&#x3002;&#x9009;&#x62E9;&#x8FD9;&#x6837;&#x7684;&#x8FB9;&#x6570;&#x6700;&#x5927;&#x7684;&#x5B50;&#x96C6;&#x79F0;&#x4E3A;&#x56FE;&#x7684;&#x6700;&#x5927;&#x5339;&#x914D;&#x95EE;&#x9898;&#x3002;&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x5339;&#x914D;&#x4E2D;&#xFF0C;&#x56FE;&#x4E2D;&#x7684;&#x6BCF;&#x4E2A;&#x9876;&#x70B9;&#x90FD;&#x548C;&#x56FE;&#x4E2D;&#x67D0;&#x6761;&#x8FB9;&#x76F8;&#x5173;&#x8054;&#xFF0C;&#x5219;&#x79F0;&#x6B64;&#x5339;&#x914D;&#x4E3A;&#x5B8C;&#x5168;&#x5339;&#x914D;&#xFF0C;&#x4E5F;&#x79F0;&#x4F5C;&#x5B8C;&#x5907;&#x5339;&#x914D;&#x3002;&#x6C42;&#x4E8C;&#x5206;&#x56FE;&#x5339;&#x914D;&#x53EF;&#x4EE5;&#x7528;&#x6700;&#x5927;&#x6D41;(Maximal Flow)&#x6216;&#x8005;&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;(Hungarian Algorithm)&#x3002;
&#x5B8C;&#x5168;&#x5339;&#x914D;&#x4E00;&#x5B9A;&#x662F;&#x6781;&#x5927;&#x5339;&#x914D;&#xFF0C;&#x4F46;&#x662F;&#x6781;&#x5927;&#x5339;&#x914D;&#x4E0D;&#x4E00;&#x5B9A;&#x662F;&#x5B8C;&#x5168;&#x5339;&#x914D;&#x3002;&#x4E0B;&#x56FE;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x6700;&#x5927;&#x5339;&#x914D;&#x3002;</p>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201205211423.png" alt="image-20201205211423739"></p>
<h3 id="2&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x5224;&#x65AD;"><a name="2&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x5224;&#x65AD;" class="anchor-navigation-ex-anchor" href="#2&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x5224;&#x65AD;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x5224;&#x65AD;" class="plugin-anchor" href="#2&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x5224;&#x65AD;"><i class="fa fa-link" aria-hidden="true"></i></a>2.&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x5224;&#x65AD;</h3>
<p>&#x5BF9;&#x4E8E;&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x95EE;&#x9898;&#x6211;&#x4EEC;&#x9996;&#x5148;&#x8981;&#x5224;&#x65AD;&#x4E00;&#x4E2A;&#x56FE;&#x5B83;&#x662F;&#x4E0D;&#x662F;&#x4E8C;&#x5206;&#x56FE;&#x3002;&#x5BF9;&#x4E8E;&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x5224;&#x65AD;&#x65B9;&#x6CD5;&#x6700;&#x5E38;&#x89C1;&#x7684;&#x662F;&#x67D3;&#x8272;&#x6CD5;&#xFF0C;&#x987E;&#x540D;&#x601D;&#x4E49;&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x5BF9;&#x6BCF;&#x4E00;&#x4E2A;&#x70B9;&#x8FDB;&#x884C;&#x67D3;&#x8272;&#x64CD;&#x4F5C;&#xFF0C;&#x6211;&#x4EEC;&#x53EA;&#x7528;&#x9ED1;&#x767D;&#x4E24;&#x79CD;&#x989C;&#x8272;&#xFF0C;&#x95EE;&#x80FD;&#x4E0D;&#x80FD;&#x4F7F;&#x6240;&#x6709;&#x7684;&#x70B9;&#x90FD;&#x67D3;&#x4E0A;&#x4E86;&#x8272;&#xFF0C;&#x800C;&#x4E14;&#x76F8;&#x90BB;&#x4E24;&#x4E2A;&#x70B9;&#x7684;&#x989C;&#x8272;&#x4E0D;&#x540C;&#xFF0C;&#x5982;&#x679C;&#x53EF;&#x4EE5;&#x90A3;&#x4E48;&#x8FD9;&#x4E2A;&#x56FE;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x4E8C;&#x5206;&#x56FE;&#xFF0C;&#x5BF9;&#x4E8E;&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x4E00;&#x4E2A;&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x7528;dfs&#x548C;bfs&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x53BB;&#x5B9E;&#x73B0;&#x3002;&#x4E0B;&#x9762;&#x6211;&#x5C31;&#x4E0A;&#x4E00;&#x4E2A;bfs&#x7684;&#x5224;&#x65AD;&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x4EE3;&#x7801;&#x3002;</p>
<p><strong>BFS&#x5224;&#x65AD;&#x4E8C;&#x5206;&#x56FE;code&#xFF1A;</strong></p>
<pre><code class="lang-cpp"><span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; G[maxn];  <span class="hljs-comment">// &#x5B58;&#x8FB9;</span>
<span class="hljs-keyword">int</span> col[maxn];        <span class="hljs-comment">// &#x6807;&#x8BB0;&#x9876;&#x70B9;&#x989C;&#x8272;</span>
<span class="hljs-keyword">int</span> n,m;         <span class="hljs-comment">// &#x70B9;&#x548C;&#x8FB9;&#x7684;&#x4E2A;&#x6570;</span>
<span class="hljs-function"><span class="hljs-keyword">bool</span> <span class="hljs-title">bfs</span><span class="hljs-params">()</span></span>{
  <span class="hljs-built_in">queue</span>&lt;<span class="hljs-keyword">int</span>&gt; q;
  q.push(<span class="hljs-number">1</span>);     <span class="hljs-comment">// &#x653E;&#x5165;&#x7B2C;&#x4E00;&#x4E2A;&#x70B9;</span>
  <span class="hljs-built_in">memset</span>(col,<span class="hljs-number">0</span>,<span class="hljs-keyword">sizeof</span>(col));
  col[<span class="hljs-number">1</span>] = <span class="hljs-number">1</span>;    <span class="hljs-comment">// &#x5148;&#x6807;&#x8BB0;&#x7B2C;&#x4E00;&#x4E2A;&#x70B9;&#x4E3A;1</span>
  <span class="hljs-keyword">while</span>(!q.empty()){
    <span class="hljs-keyword">int</span> v = q.front();
    q.pop();
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span>;i&lt;G[v].size();i++){
      <span class="hljs-keyword">int</span> xx = G[v][i];
      <span class="hljs-keyword">if</span>(col[xx] == <span class="hljs-number">0</span>){      <span class="hljs-comment">// &#x5224;&#x65AD;&#x8FD9;&#x4E2A;&#x70B9;&#x662F;&#x5426;&#x6807;&#x8BB0;&#x8FC7;</span>
        col[xx] = -col[v];   <span class="hljs-comment">// &#x6CA1;&#x6709;&#x6807;&#x8BB0;&#x8FC7;&#x5C31;&#x6807;&#x8BB0;&#x4E0A;&#x4E0E;v&#x76F8;&#x53CD;&#x7684;&#x989C;&#x8272;</span>
        q.push(xx);
      }
      <span class="hljs-keyword">else</span>{
        <span class="hljs-keyword">if</span>(col[v] == col[xx]){    <span class="hljs-comment">// &#x5982;&#x679C;&#x989C;&#x8272;&#x51B2;&#x7A81;&#x8BF4;&#x660E;&#x4E0D;&#x662F;&#x4E8C;&#x5206;&#x56FE;</span>
          <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
        }
      }
    }
  }
  <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
}
</code></pre>
<h3 id="3&#x6700;&#x5927;&#x5339;&#x914D;"><a name="3&#x6700;&#x5927;&#x5339;&#x914D;" class="anchor-navigation-ex-anchor" href="#3&#x6700;&#x5927;&#x5339;&#x914D;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="3&#x6700;&#x5927;&#x5339;&#x914D;" class="plugin-anchor" href="#3&#x6700;&#x5927;&#x5339;&#x914D;"><i class="fa fa-link" aria-hidden="true"></i></a>3.&#x6700;&#x5927;&#x5339;&#x914D;</h3>
<p>&#x7ED9;&#x5B9A;&#x4E00;&#x4E2A;&#x4E8C;&#x5206;&#x56FE;G&#xFF0C;&#x5728;G&#x7684;&#x4E00;&#x4E2A;&#x5B50;&#x56FE;M&#x4E2D;&#xFF0C;M&#x7684;&#x8FB9;&#x96C6;&#x4E2D;&#x7684;&#x4EFB;&#x610F;&#x4E24;&#x6761;&#x8FB9;&#x90FD;&#x4E0D;&#x4F9D;&#x9644;&#x4E8E;&#x540C;&#x4E00;&#x4E2A;&#x9876;&#x70B9;&#xFF0C;&#x5219;&#x79F0;M&#x662F;&#x4E00;&#x4E2A;&#x5339;&#x914D;&#x3002;&#x9009;&#x62E9;&#x8FD9;&#x6837;&#x7684;&#x8FB9;&#x6570;&#x6700;&#x5927;&#x7684;&#x5B50;&#x96C6;&#x79F0;&#x4E3A;&#x56FE;&#x7684;&#x6700;&#x5927;&#x5339;&#x914D;&#x95EE;&#x9898;&#xFF08;maximal matching problem)&#x3002;</p>
<p><strong>&#x9996;&#x5148;&#x6211;&#x4EEC;&#x5148;&#x4E86;&#x89E3;&#x4E24;&#x4E2A;&#x6982;&#x5FF5;</strong></p>
<p>&#x4EA4;&#x66FF;&#x8DEF;&#xFF1A;&#x4ECE;&#x4E00;&#x4E2A;&#x672A;&#x5339;&#x914D;&#x7684;&#x70B9;&#x51FA;&#x53D1;&#xFF0C;&#x4F9D;&#x6B21;&#x7ECF;&#x8FC7;&#x672A;&#x5339;&#x914D;&#x8FB9;&#x3001;&#x5339;&#x914D;&#x8FB9;&#x3001;&#x672A;&#x5339;&#x914D;&#x8FB9;....&#x8FD9;&#x6837;&#x7684;&#x8DEF;&#x53EB;&#x505A;&#x4EA4;&#x66FF;&#x8DEF;&#x3002;</p>
<p>&#x589E;&#x5E7F;&#x8DEF;&#xFF1A;&#x4ECE;&#x4E00;&#x4E2A;&#x672A;&#x5339;&#x914D;&#x7684;&#x70B9;&#x51FA;&#x53D1;&#xFF0C;&#x8D70;&#x4EA4;&#x66FF;&#x8DEF;&#xFF0C;&#x5230;&#x8FBE;&#x4E86;&#x4E00;&#x4E2A;&#x672A;&#x5339;&#x914D;&#x8FC7;&#x7684;&#x70B9;&#xFF0C;&#x8FD9;&#x6761;&#x8DEF;&#x53EB;&#x505A;&#x589E;&#x5E7F;&#x8DEF;&#x3002;
&#x770B;&#x4E0B;&#x56FE;&#xFF0C;&#x5176;&#x4E2D;1&#x3001;4&#x3001;5&#x3001;7&#x662F;&#x5DF2;&#x7ECF;&#x5339;&#x914D;&#x7684;&#x70B9;&#xFF0C;1-&gt;5,4-&gt;7&#x662F;&#x5DF2;&#x7ECF;&#x5339;&#x914D;&#x7684;&#x8FB9;&#xFF0C;&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x4ECE;8&#x5F00;&#x59CB;&#x51FA;&#x53D1;&#xFF0C;8-&gt;4-&gt;7-&gt;1-&gt;5-&gt;2&#x8FD9;&#x6761;&#x8DEF;&#x5C31;&#x662F;&#x4E00;&#x6761;&#x589E;&#x5E7F;&#x8DEF;&#x3002;</p>
<p><img src="https://pic4.zhimg.com/80/v2-2663ce7262f59001bc3803b615b6b523_720w.jpg" alt="img"></p>
<p>&#x4E3A;&#x4EC0;&#x4E48;&#x6211;&#x4EEC;&#x8981;&#x53BB;&#x627E;&#x589E;&#x5E7F;&#x8DEF;&#x5462;&#xFF1F;</p>
<p>&#x56E0;&#x4E3A;&#x63A5;&#x4E0B;&#x6765;&#x8981;&#x8BB2;&#x7684;&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;&#x5C31;&#x662F;&#x53BB;&#x5BFB;&#x627E;&#x589E;&#x5E7F;&#x8DEF;&#x800C;&#x6C42;&#x51FA;&#x6700;&#x5927;&#x5339;&#x914D;&#x6570;&#x7684;(&#x4E00;&#x53E5;&#x5E9F;&#x8BDD;)&#xFF0C;&#x5BF9;&#x4E8E;&#x6C42;&#x4E8C;&#x5206;&#x56FE;&#x6700;&#x5927;&#x5339;&#x914D;&#x7684;&#x7B97;&#x6CD5;&#x53EF;&#x4EE5;&#x7528;&#x7F51;&#x7EDC;&#x6D41;&#x53BB;&#x8DD1;&#x4E00;&#x4E2A;&#x6700;&#x5927;&#x6D41;&#x6C42;&#x89E3;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x7528;&#x4E8C;&#x5206;&#x56FE;&#x7684;&#x5E38;&#x89C1;&#x7B97;&#x6CD5;&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;(Hungarian Algorithm)&#xFF0C;&#x8FD9;&#x91CC;&#x6211;&#x5C31;&#x53EA;&#x8BB2;&#x4E00;&#x4E0B;&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;&#xFF0C;&#x8FD9;&#x4E2A;&#x7B97;&#x6CD5;&#x7684;&#x6838;&#x5FC3;&#x5C31;&#x662F;&#x53BB;&#x627E;&#x672A;&#x5339;&#x914D;&#x7684;&#x70B9;&#xFF0C;&#x7136;&#x540E;&#x4ECE;&#x8FD9;&#x4E2A;&#x70B9;&#x51FA;&#x53D1;&#x53BB;&#x5BFB;&#x627E;&#x589E;&#x5E7F;&#x8DEF;&#xFF0C;&#x56E0;&#x4E3A;&#x589E;&#x5E7F;&#x8DEF;&#x6709;&#x51E0;&#x4E2A;&#x4E3B;&#x8981;&#x7684;&#x7279;&#x70B9;&#xFF1A;</p>
<p>\1. &#x589E;&#x5E7F;&#x8DEF;&#x6709;&#x5947;&#x6570;&#x6761;&#x8FB9; &#x3002;
\2. &#x8DEF;&#x5F84;&#x4E0A;&#x7684;&#x70B9;&#x4E00;&#x5B9A;&#x662F;&#x4E00;&#x4E2A;&#x5728;X&#x8FB9;&#xFF0C;&#x4E00;&#x4E2A;&#x5728;Y&#x8FB9;&#xFF0C;&#x4EA4;&#x9519;&#x51FA;&#x73B0;&#x3002;
\3. &#x8D77;&#x70B9;&#x548C;&#x7EC8;&#x70B9;&#x90FD;&#x662F;&#x76EE;&#x524D;&#x8FD8;&#x6CA1;&#x6709;&#x914D;&#x5BF9;&#x7684;&#x70B9;&#x3002;
\4. &#x672A;&#x5339;&#x914D;&#x8FB9;&#x7684;&#x6570;&#x91CF;&#x6BD4;&#x5339;&#x914D;&#x8FB9;&#x7684;&#x6570;&#x91CF;&#x591A;1&#x3002;</p>
<p>&#x91CD;&#x70B9;&#x662F;&#x7B2C;4&#x70B9;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x6B64;&#x7279;&#x6027;&#xFF0C;&#x628A;&#x8FD9;&#x6761;&#x589E;&#x5E7F;&#x8DEF;&#x4E2D;&#x7684;&#x5339;&#x914D;&#x8FB9;&#x6539;&#x4E3A;&#x672A;&#x5339;&#x914D;&#x8FB9;&#xFF0C;&#x628A;&#x672A;&#x5339;&#x914D;&#x8FB9;&#x6539;&#x4E3A;&#x5339;&#x914D;&#x8FB9;&#xFF0C;&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x603B;&#x5339;&#x914D;&#x8FB9;&#x6570;+1&#x4E86;&#xFF0C;&#x6839;&#x636E;&#x4E0A;&#x9762;&#x7684;&#x56FE;&#x5F97;&#x51FA;&#x4E0B;&#x56FE;&#xFF0C;&#x5F88;&#x663E;&#x7136;&#x5339;&#x914D;&#x8FB9;&#x591A;&#x4E86;&#x4E00;&#x6761;&#x3002;</p>
<p><img src="https://pic4.zhimg.com/80/v2-791706dc06d0fc6d3a72102fed0787e3_720w.jpg" alt="img"></p>
<h3 id="4&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;"><a name="4&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#4&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="4&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;" class="plugin-anchor" href="#4&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>4.&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;</strong></h3>
<p><strong><em>\</em>&#x4E8C;. &#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;**</strong></p>
<p>&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x8BA8;&#x8BBA;&#x4E0B;&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;&#x7684;&#x5185;&#x5BB9;&#xFF1A;</p>
<ol>
<li><strong>&#x7ED9;&#x5B9A;&#x4E00;&#x4E2A;&#x56FE;</strong>&#xFF1A;</li>
</ol>
<p><img src="https://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWFnZXMyMDE1LmNuYmxvZ3MuY29tL2Jsb2cvODkyNzU4LzIwMTYwNi84OTI3NTgtMjAxNjA2MTAxNTUzNTExMjEtNDc5Mzk4NDIucG5n?x-oss-process=image/format,png" alt="img"></p>
<p>&#x524D;&#x9762;&#x5DF2;&#x7ECF;&#x8BF4;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x8BA8;&#x8BBA;&#x7684;&#x57FA;&#x7840;&#x662F;&#x4E8C;&#x90E8;&#x56FE;&#xFF0C;&#x800C;&#x4E0A;&#x56FE;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x4E8C;&#x90E8;&#x56FE;&#xFF0C;&#x6211;&#x4EEC;&#x4ECE;&#x4E0A;&#x56FE;&#x7684;&#x5DE6;&#x8FB9;&#x5F00;&#x59CB;&#x8BA8;&#x8BBA;&#xFF0C;<strong><em>\</em>&#x6211;&#x4EEC;&#x7684;&#x76EE;&#x6807;&#x662F;&#x5C3D;&#x53EF;&#x80FD;&#x7ED9;x&#x4E2D;&#x6700;&#x591A;&#x7684;&#x70B9;&#x627E;&#x5230;&#x914D;&#x5BF9;&#x3002;**</strong></p>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x6700;&#x5927;&#x5339;&#x914D;&#x662F;&#x4E92;&#x76F8;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x7ED9;X&#x627E;&#x5230;&#x4E86;&#x6700;&#x591A;&#x7684;Y&#x4E2D;&#x7684;&#x5BF9;&#x5E94;&#x70B9;&#xFF0C;&#x540C;&#x6837;&#xFF0C;Y&#x4E2D;&#x4E5F;&#x4E0D;&#x53EF;&#x80FD;&#x6709;&#x66F4;&#x591A;&#x7684;&#x70B9;&#x5F97;&#x5230;&#x5339;&#x914D;&#x4E86;&#x3002;</p>
<p>&#x521A;&#x5F00;&#x59CB;&#xFF0C;&#x4E00;&#x4E2A;&#x5339;&#x914D;&#x90FD;&#x6CA1;&#x6709;&#xFF0C;&#x6211;&#x4EEC;&#x968F;&#x610F;&#x9009;&#x53D6;&#x4E00;&#x6761;&#x8FB9;&#xFF0C;&#xFF08;x1, y1&#xFF09;&#x8FD9;&#x6761;&#x8FB9;&#xFF0C;&#x6784;&#x5EFA;&#x6700;&#x521D;&#x7684;&#x5339;&#x914D;&#x51FA;&#x6765;&#xFF0C;&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#xFF0C;&#x5DF2;&#x7ECF;&#x914D;&#x5BF9;&#x7684;&#x8FB9;&#x7528;&#x7C97;&#x7EBF;&#x6807;&#x51FA;&#xFF1A;</p>
<p><img src="https://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWFnZXMyMDE1LmNuYmxvZ3MuY29tL2Jsb2cvODkyNzU4LzIwMTYwNi84OTI3NTgtMjAxNjA2MTAxNTU0MDU2NTItMTAyMjkzNDc0MS5wbmc?x-oss-process=image/format,png" alt="img"></p>
<ol>
<li><strong>&#x6211;&#x4EEC;&#x7ED9;x2&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x5339;&#x914D;&#xFF0C;&#x5982;&#x4E0B;&#x56FE;&#x7684;&#xFF08;x2, y2&#xFF09;&#x8FB9;&#x3002;</strong></li>
</ol>
<p><img src="https://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWFnZXMyMDE1LmNuYmxvZ3MuY29tL2Jsb2cvODkyNzU4LzIwMTYwNi84OTI3NTgtMjAxNjA2MTAxNTU0MTE3MTUtOTU1MzQyNTg0LnBuZw?x-oss-process=image/format,png" alt="img"></p>
<p>&#x76EE;&#x524D;&#x6765;&#x770B;&#xFF0C;&#x4E00;&#x5207;&#x90FD;&#x5F88;&#x987A;&#x5229;&#xFF0C;&#x5230;&#x8FD9;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x5F62;&#x6210;&#x4E86;&#x5339;&#x914D;M&#xFF0C;&#x5176;&#x6709;&#xFF08;x1, y1&#xFF09;, (x2, y2 ) &#x4E24;&#x6761;&#x8FB9;&#x3002;</p>
<p>\3. &#x6211;&#x4EEC;&#x73B0;&#x5728;&#x60F3;&#x7ED9;<strong>x3</strong>&#x5339;&#x914D;&#x4E00;&#x6761;&#x8FB9;&#xFF0C;&#x53D1;&#x73B0;&#x5B83;&#x7684;&#x53E6;&#x4E00;&#x7AEF;<strong>y1</strong>&#x5DF2;&#x7ECF;&#x88AB;<strong><em>\</em>x1**</strong>&#x5360;&#x7528;&#x4E86;&#xFF0C;&#x90A3;x3&#x5C31;&#x4E0D;&#x9AD8;&#x5174;&#x4E86;&#xFF0C;&#x5B83;&#x5C31;&#x53BB;&#x627E;y1&#x6E38;&#x8BF4;&#xFF0C;&#x8BA9;y1&#x79BB;&#x5F00;x1&#x3002;</p>
<p>&#x5373;&#x5C06;&#x88AB;&#x8FEB;&#x5206;&#x624B;&#x7684;x1&#x5F88;&#x59D4;&#x5C48;&#xFF0C;&#x597D;&#x5728;&#x5B83;&#x8FD8;&#x6709;&#x5176;&#x4ED6;&#x7684;&#x9009;&#x62E9;&#xFF0C;&#x4E8E;&#x662F; x1 &#x59A5;&#x534F;&#x4E86;&#xFF0C;&#x51C6;&#x5907;&#x53BB;&#x627E;&#x81EA;&#x5DF1;&#x770B;&#x4E2D;&#x7684;<strong>y2</strong>&#x3002;</p>
<p>&#x4F46;&#x5F88;&#x5FEB;&#xFF0C;x1&#x53D1;&#x73B0; y2 &#x88AB;x2 &#x770B;&#x4E2D;&#x4E86;&#xFF0C;&#x5B83;&#x5C31;&#x60F3;&#x554A;&#xFF0C;y1 &#x629B;&#x5F03;&#x4E86;&#x6211;&#xFF0C;&#x90A3;&#x6211;&#x5C31;&#x8BA9; y2 &#x4E3B;&#x52A8;&#x79BB;&#x5F00; <strong><em>\</em>x2 &#xFF08;&#x5F88;&#x660E;&#x663E;&#xFF0C;&#x8FD9;&#x662F;&#x4E2A;&#x9012;&#x5F52;&#x7684;&#x8FC7;&#x7A0B;&#xFF09;**</strong>&#x3002;</p>
<p>x2 &#x8BE5;&#x600E;&#x4E48;&#x529E;&#x5462;&#xFF1F;&#x597D;&#x5728;&#x5929;&#x65E0;&#x7EDD;&#x4EBA;&#x4E4B;&#x8DEF;&#xFF0C;&#x5B83;&#x53BB;&#x627E;&#x4E86;<strong>y5</strong>&#x3002;</p>
<p>&#x8C22;&#x5929;&#x8C22;&#x5730;&#xFF0C;y5 &#x8FD8;&#x6CA1;&#x6709;&#x540D;&#x82B1;&#x6709;&#x4E3B;&#xFF0C;&#x7EC8;&#x4E8E;&#x7686;&#x5927;&#x6B22;&#x559C;&#x3002;</p>
<p>&#x5339;&#x914D;&#x5982;&#x4E0B;&#xFF1A;</p>
<p><img src="https://img-blog.csdnimg.cn/2019053117173052.png" alt="img"></p>
<p>&#x4E0A;&#x9762;&#x8FD9;&#x4E2A;&#x4E89;&#x8BBA;&#x4E0E;&#x59A5;&#x534F;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x628A;&#x7275;&#x6D89;&#x5230;&#x7684;&#x8282;&#x70B9;&#x90FD;&#x62FF;&#x51FA;&#x6765;&#xFF1A;&#xFF08;x3, y1, x1, y2, x2, y5&#xFF09;&#xFF0C;&#x5F88;&#x660E;&#x663E;&#xFF0C;&#x8FD9;&#x662F;&#x4E00;&#x6761;&#x8DEF;&#x5F84;P&#x3002;</p>
<p>&#x800C;&#x5728;&#x7B2C;&#x4E8C;&#x6B65;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5F62;&#x6210;&#x4E86;&#x5339;&#x914D;M&#xFF0C;&#x800C;P&#x5462;&#xFF1F;&#x8FD8;&#x8BB0;&#x5F97;&#x589E;&#x5E7F;&#x8DEF;&#x5F84;&#x4E48;&#xFF0C;&#x6211;&#x4EEC;&#x53D1;&#x73B0;&#xFF0C;P&#x539F;&#x6765;&#x662F;M&#x7684;&#x4E00;&#x6761;&#x589E;&#x5E7F;&#x8DEF;&#x5F84;&#xFF01;</p>
<p>&#x4E0A;&#x6587;&#x5DF2;&#x7ECF;&#x8BF4;&#x8FC7;&#xFF0C;&#x53D1;&#x73B0;&#x4E00;&#x6761;&#x589E;&#x5E7F;&#x8DEF;&#x5F84;&#xFF0C;&#x5C31;&#x610F;&#x5473;&#x7740;&#x4E00;&#x4E2A;&#x66F4;&#x5927;&#x5339;&#x914D;&#x7684;&#x51FA;&#x73B0;&#xFF0C;&#x4E8E;&#x662F;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;M&#x4E2D;&#x7684;&#x914D;&#x5BF9;&#x70B9;&#x62C6;&#x5206;&#x5F00;&#xFF0C;&#x91CD;&#x65B0;&#x7EC4;&#x5408;&#xFF0C;&#x5F97;&#x5230;&#x4E86;&#x4E00;&#x4E2A;&#x66F4;&#x5927;&#x5339;&#x914D;&#xFF0C;M1, &#x5176;&#x62E5;&#x6709;&#xFF08;x3, y1&#xFF09;,(x1, y2), (x2, y5)&#x4E09;&#x6761;&#x8FB9;&#x3002;</p>
<p>&#x800C;&#x8FD9;&#xFF0C;&#x5C31;&#x662F;&#x5308;&#x7259;&#x5229;&#x7B97;&#x6CD5;&#x7684;&#x7CBE;&#x9AD3;&#x3002;</p>
<p>&#x540C;&#x6837;&#xFF0C;x4 , x5 &#x6309;&#x987A;&#x5E8F;&#x52A0;&#x5165;&#x8FDB;&#x6765;&#xFF0C;&#x6700;&#x7EC8;&#x4F1A;&#x5F97;&#x5230;&#x672C;&#x56FE;&#x7684;&#x6700;&#x5927;&#x5339;&#x914D;&#x3002;</p>
<p><img src="https://img-blog.csdnimg.cn/20190531172740669.png" alt="img"></p>
<p>&#x5F97;&#x5230;&#x8FD9;&#x4E2A;&#x7ED3;&#x679C;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x53D1;&#x73B0;&#xFF0C;&#x5176;&#x5B9E;&#x4E5F;&#x53EF;&#x4EE5;&#x628A;y4 &#x8BA9;&#x7ED9; x6 , &#x8FD9;&#x6837;x5 &#x5C31;&#x4F1A;&#x7A7A;&#x7F6E;&#xFF0C;&#x4F46;&#x5E76;&#x4E0D;&#x5F71;&#x54CD;&#x6700;&#x5927;&#x5339;&#x914D;&#x7684;&#x5927;&#x5C0F;&#x3002;</p>
<pre><code class="lang-cpp"><span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; G[maxn];    <span class="hljs-comment">// &#x5B58;&#x8FB9;</span>
<span class="hljs-keyword">int</span> pre[maxn];     <span class="hljs-comment">// &#x8BB0;&#x5F55;&#x5339;&#x914D;&#x70B9;</span>
<span class="hljs-keyword">bool</span> vis[maxn];    <span class="hljs-comment">// &#x6807;&#x8BB0;&#x662F;&#x5426;&#x5339;&#x914D;&#x8FC7;</span>
<span class="hljs-keyword">int</span> n,m;           <span class="hljs-comment">// n&#x4E2A;&#x70B9; m&#x6761;&#x8FB9;</span>
<span class="hljs-function"><span class="hljs-keyword">bool</span> <span class="hljs-title">dfs</span><span class="hljs-params">(<span class="hljs-keyword">int</span> x)</span></span>{
  <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span>;i&lt;G[x].size();i++){
    <span class="hljs-keyword">int</span> v = G[x][i];
    <span class="hljs-keyword">if</span>(vis[v] == <span class="hljs-literal">false</span>){       <span class="hljs-comment">// &#x5224;&#x65AD;&#x662F;&#x5426;&#x6807;&#x8BB0;&#x8FC7;</span>
      vis[v] = <span class="hljs-literal">true</span>;
      <span class="hljs-keyword">if</span>(pre[v] == <span class="hljs-number">-1</span> || dfs(pre[v])){      <span class="hljs-comment">// &#x5224;&#x65AD;&#x5F53;&#x524D;&#x70B9;&#x662F;&#x5426;&#x5339;&#x914D;&#x8FC7; dfs&#x4E3A;&#x5224;&#x65AD;&#x8FD9;&#x4E2A;&#x70B9;&#x80FD;&#x4E0D;&#x80FD;&#x548C;&#x5176;&#x4ED6;&#x7684;&#x70B9;&#x5339;&#x914D;</span>
        pre[v] = x;
        <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
      }
    }
  }
  <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
}
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">Fun</span><span class="hljs-params">()</span></span>{
  <span class="hljs-keyword">int</span> sum = <span class="hljs-number">0</span>;
  <span class="hljs-built_in">memset</span>(pre,<span class="hljs-number">-1</span>,<span class="hljs-keyword">sizeof</span>(pre));
  <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">1</span>;i&lt;=n;i++){
    <span class="hljs-built_in">memset</span>(vis,<span class="hljs-literal">false</span>,<span class="hljs-keyword">sizeof</span>(vis));     <span class="hljs-comment">// &#x6BCF;&#x6B21;&#x904D;&#x5386;&#x90FD;&#x9700;&#x8981;&#x521D;&#x59CB;&#x5316;</span>
    <span class="hljs-keyword">if</span>(dfs(i)) sum ++;
  }
  <span class="hljs-keyword">return</span> sum;
}
</code></pre>

<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../计算机网络/9.面试题二.html" class="navigation navigation-prev " aria-label="Previous page: 面试题总结一">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="2.图论例题.html" class="navigation navigation-next " aria-label="Next page: 2.图论例题">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"1.图论","level":"3.1","depth":1,"next":{"title":"2.图论例题","level":"3.2","depth":1,"path":"数据结构/2.图论例题.md","ref":"数据结构/2.图论例题.md","articles":[]},"previous":{"title":"面试题总结一","level":"2.10","depth":1,"path":"计算机网络/9.面试题二.md","ref":"计算机网络/9.面试题二.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","sharing-plus","anchor-navigation-ex","favicon","expandable-chapters","toggle-chapters","back-to-top-button","code","-lunr","-search","search-pro","pageview-count","popup","livereload"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"livereload":{},"splitter":{},"search-pro":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"popup":{},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{},"back-to-top-button":{},"pageview-count":{},"expandable-chapters-small":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"toggle-chapters":{},"expandable-chapters":{}},"theme":"default","author":"hzh","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"计算机 ,java , 大数据 基础知识体系","language":"zh-hans","gitbook":"3.2.3"},"file":{"path":"数据结构/1.图论.md","mtime":"2020-12-10T09:23:41.958Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-12-30T11:12:56.611Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

